package com.newland.starpos.sms.controller;

import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.google.gson.JsonObject;
import com.newland.starpos.sms.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping({"/cloudpos/sms"})
public class SendSmsController {

    @Autowired
    private SmsService smsService;

    @PostMapping(value = "/singleSendSms")
    public SendSmsResponse sendSingle(@RequestBody Map<String, String> request) {
        log.info("start sending a single text message");
        String signName = request.get("signname");
        String templateCode = request.get("templatecode");
        String paramString = request.get("paramstring");
        String recNum = request.get("recnum");

        log.info("request param: {}", request.toString());
        return smsService.sendSingle(signName, templateCode, paramString, recNum);
    }

}
